#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const int N = 1e5;

vector<int> edges[N];
int fa[N],dist[N];

int dfs(int u){
	int ret = 0;
	for(auto v : edges[u]){
		ret = max(ret,dfs(v));
	}
	return ret + 1;
}

int bfs(){
	queue<int> q;
	q.push(1);
	int ret = 0;
	while(q.size()){
		int sz = q.size();
		ret = max(ret,sz);
		while(sz--){
			int u = q.front();
			q.pop();
			for(auto v : edges[u]){
				q.push(v);
			}
		}
	}
	return ret;
}

int main(){
	int n;
	cin >> n;
	for(int i = 1;i < n;i++){
		int a,b;
		cin >> a >> b;
		edges[a].push_back(b); 
		fa[b] = a;
	}
	
	cout << dfs(1) << endl;
	
	cout << bfs() << endl;
	
	int x,y;
	cin >> x >> y;
	while(x != 1){
		dist[fa[x]] = dist[x] + 1;
		x = fa[x];
	}
	
	int len = 0;
	while(y != 1 && dist[y] == 0){
		len++;
		y = fa[y];
	}
	
	cout << dist[y] * 2 + len << endl;
	
	return 0;
}
